import Emitter from "../../Framework/Common/Emitter";
import Singlelon from "../../Framework/Common/Singlelon";
import UIWindow from "../../Framework/UIFramework/UIWindow";
import ModuleMgr from "../Game/Module/ModuleMgr";
import { PoolManager } from "../Game/Module/NodePool";

const { ccclass, property } = cc._decorator;
@ccclass
export default class GameOver extends UIWindow {
    private _livingPlayer: number = null;
    private _lb: cc.Label = null;
    constructor() {
        super();
    }
    onInit(index: number): void {
        this._lb = this.getComp("_title", "Label");
        if (index === 1) {
            this._lb.string = "玩家一胜利";
        } else {
            this._lb.string = "玩家二胜利";
        }
        this.onClickListner("_BackToMenu", this.onBackMenu)
    }

    onBackMenu() {
        this.openUI("Menu", true, true);
        this.closeUI("MainUI", true);
        //清除所有消息机制
        Emitter.instance.off();
        Emitter.release();
        //清空所有模块
        ModuleMgr.instance.clearModule();
        ModuleMgr.release();
        //清空所有对象池
        PoolManager.instance.clearPoolMap();
        let gameNode = cc.find("Canvas/Game");
        gameNode.destroy();
    }

}
